import type { ComponentPropertiesResponse, EWebDesignerComponentCategory, WebDesignerComponentInfo } from '@/api/designer/model'

// 基础组件
export type Title01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['title01']>
export type Carousel01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['carousel01']>
export type Navigation01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['navigation01']>
export type Introduction01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['introduction01']>
export type Statistics01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['statistics01']>
export type Course01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['course01']>
// 内容组件
export type Teacher01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['teacher01']>
export type Advantage01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['advantage01']>
export type Flow01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['flow01']>
export type Button01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['button01']>
export type Album01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['album01']>
export type Video01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['video01']>
export type QuestionAnswer01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['questionAnswer01']>
export type Honor01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['honor01']>
export type Information01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['information01']>
export type Campus01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['campus01']>
export type Evaluation01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['evaluation01']>
// 营销组件
export type Consultation01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['consultation01']>
export type Guide01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['guide01']>
export type Feedback01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['feedback01']>
export type Attention01ComponentMeta = ComponentMeta<ComponentPropertiesResponse['attention01']>

export type ComponentCode = keyof ComponentPropertiesResponse
export interface ComponentDefinition {
  readonly category: EWebDesignerComponentCategory
  readonly icon: string
  readonly text: string
  readonly items: ComponentDefinitionItem[]
}
export interface ComponentDefinitionItem extends WebDesignerComponentInfo {
  /** 编码（唯一标识） */
  code?: ComponentCode
}
export interface ComponentMeta<Config = any> {
  /** will be generated when creating */
  readonly id?: string
  readonly definition: Readonly<ComponentDefinitionItem>
  config: Config
}
export interface SliderAttr {
  min?: number
  max?: number
  value: number
  label: string
}

export enum JumpType {
  /** 无 */
  None = 0,
  /** 栏目 */
  Column = 1,
  /** 课程 */
  Course = 2,
  /** 资讯 */
  News = 3,
  /** 师资 */
  Teacher = 4,
  /** 问答 */
  QA = 5,
  /** 相册 */
  Album = 6,
  /** 咨询 */
  Consult = 7,
  /** 页面 */
  Page = 8,
  /** 校区 */
  Teachs = 9,
}
export const JumpTypeMap = new Map<JumpType, string>([
  [JumpType.None, '无链接'],
  [JumpType.Column, '栏目'],
  [JumpType.Course, '课程'],
  [JumpType.News, '资讯'],
  [JumpType.Teacher, '师资'],
  [JumpType.QA, '问答'],
  [JumpType.Album, '相册'],
  [JumpType.Page, '页面'],
  [JumpType.Consult, '咨询'],
  [JumpType.Teachs, '校区'],
])
/**
 * `JumpType.Consult`时:
 * 
 * 这几个要做特殊处理。
 * -  调美洽的 div，给个 class 例如：xxx-designer-meiqia
 * -  电话的直接唤起打电话。
 * -  链接 target。
 * -  客服 target
 */
export enum JumpConsultMethod {
  /** 美洽 */
  MeiQia = 0,
  /** 电话 */
  DianHua = 1,
  /** 自定链接 */
  CustomLink = 2,
  /** 企业微信客服 */
  QWKF = 3,
}
